

const { ethers } =require('ethers');
/*react native 只支持到ethers 5.7,实测6.3不能跑*/

export function encodeHelloWorld(data)
{
    var abiStr = '[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"newname","type":"string"}],"name":"onset","type":"event"},{"inputs":[],"name":"get","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"n","type":"string"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"}]';
    const iface = new ethers.utils.Interface(abiStr);
    var res = iface.encodeFunctionData("set",[data]);
    console.log("encode result: "+res);
    return res;
}
